from flask import Blueprint,render_template,g,redirect,request,url_for,jsonify
from app.method.path_show import graphupdate,findAllPath,shaixuan,getallpath


A_plan_page = Blueprint('A_plan_page',__name__,template_folder='templates')
@A_plan_page.route('/A-plan',methods = ['GET','POST'])
def A_plan():
        result=[]
        if request.method == 'POST':

            if request.values.get('fun')=='show1':
                x = {}
                value = request.values
                num = len(value)
                for i in range(0,int((num-3)/2)):
                    key1 = request.values.get('f'+str(i))

                    valx = request.values.get('s'+str(i))
                    val1 = valx.split(',')
                    x.update({key1:val1})



                start = request.values.get('start').split(',')
                end = request.values.get('end').split(',')
                allpath = getallpath( start=start, end=end,graph=x)
                result = shaixuan(allpath=allpath)


        return render_template('Aplan.html',hs_current_user='测试',mes_lists=[],mes_len=0,pathlists=result)
